- gboolean (* accept)(Device *self, DirectTCPConnection **conn,
- ProlongProc prolong, gpointer prolong_data);
- gboolean (* connect)(Device *self, gboolean for_writing, DirectTCPAddr *addrs,
- DirectTCPConnection **conn, ProlongProc prolong,
- gpointer prolong_data);
- gboolean (* write_from_connection)(Device *self, guint64 size, guint64 *actual_size);
- gboolean (* read_to_connection)(Device *self, guint64 size, guint64 *actual_size);
+ /* The MainLoop must be running, but the following 4 methods must not be
+ * called from an event. they must be called from a different thread.
+ * They return:
+ * 0 - success
+ * 1 - failed
+ * 2 - interupted
+ */
+ int (* accept)(Device *self, DirectTCPConnection **conn,
+ int *cancelled, GMutex *abort_mutex, GCond *abort_cond);
+ int (* connect)(Device *self, gboolean for_writing,
+ DirectTCPAddr *addrs, DirectTCPConnection **conn,
+ int *cancelled,
+ GMutex *abort_mutex, GCond *abort_cond);
+ int (* write_from_connection)(Device *self, guint64 size,
+ guint64 *actual_size, int *cancelled,
+ GMutex *abort_mutex, GCond *abort_cond);
+ int (* read_to_connection)(Device *self, guint64 size,
+ guint64 *actual_size, int *cancelled,
+ GMutex *abort_mutex, GCond *abort_cond);
+